/**
 * Created by user on 2016/11/30.
 */
import React from 'react';
import { Form, Row, Col, Input, Modal, Select, DatePicker, Button,  notification ,Message, Calendar, Pagination } from 'antd';


const FormItem = Form.Item;
const Option = Select.Option;

 let List = React.createClass({

   getInitialState() {
     return {
       visible: false,
       detailList:{}
     }
   },

   componentWillReceiveProps(nextProps){
     this.setState({
       visible: nextProps.visible,
       detailList: nextProps.detailList
     })
   },

   handleSubmit() {
     let forms= this.props.form.getFieldsValue();
     let params = Object.assign({},{remindId: this.props.detailList.id},forms)
     let me = this;
     console.log(params);
     Utils.sendAjax({
       url: '/job/remind/updateFeedback',
       data: JSON.stringify(params),
       callback: function(result){
         if (result.code == '200') {
           Message.success(result.message);
           
         }else {
           Message.error(result.message, 10);
         }
       }
     })

     this.props.handleCancelJobAlert();
     this.props.form.resetFields();
   },


   render() {
     let detailList = this.props.detailList;


      const { getFieldProps }  = this.props.form;
      const feedbackProps = getFieldProps('feedback', {initialValue: detailList.feedback});
      const forms = this.props.form.getFieldsValue();

    return (
     <Modal visible={this.state.visible}  onCancel={this.props.handleCancelJobAlert} footer="">
         <Form form={this.props.form}>
           <Row gutter={24}>
             <Col sm={24}>
               <FormItem label="回馈信息">
                 <Input type="textarea"  disabled={detailList.status == 1 ? true : false} {...feedbackProps}  style={{minHeight:　80,marginTop: 10}}/>
               </FormItem>
             </Col>
           </Row>
           <Row gutter={24}>
             <Col sm={24}>
               <FormItem>
                 {detailList.status == 1  ?　
                   '' :
                   <Button type="primary" style={{marginLeft: 155,marginTop: 10}} onClick={this.handleSubmit}>
                     {forms.feedback == '' ? '添加回馈信息' : '修改回馈信息'}</Button>
                 }
               </FormItem>
             </Col>
           </Row>
         </Form>
     </Modal>

    )
   }
 })

List = Form.create()(List);
export default List;